package com.by.controller;

import com.by.bean.Order;
import com.by.common.bean.ResultBean;
import com.by.common.controller.BaseController;
import com.by.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
@Api(tags = "订单")
public class OrderController extends BaseController {

    @Autowired
    OrderService orderService;

    @ApiOperation("抢购")
    @GetMapping("/order")
    public ResultBean save(int userId, int goodsId){
        String rs=orderService.save(userId,goodsId);
        return success("抢购结果",rs);//为null 没成功  不为null成功
    }

    @ApiOperation("查询订单:根据订单编号")
    @GetMapping("/order/detail")
    public ResultBean get(String orderNum) {
        Order order = orderService.getOrder(orderNum);
        return success("根据订单编号查询订单",order);
    }

}